{% extends  data.theme + "/_base.html" %}

{% import "bootstrap/wtf.html" as wtf %}

{% block title %} {{data.title}} {% endblock %}

{%- block head -%} 
{{ super() }}
{%- endblock -%}


{%- block body -%}
<div class="container">
<div class="row">
{{ super() }}
<!--div class="page-header"> </div-->
  <div class="col-lg-offset col-lg-6">
    <div class="input-group">
      <span class="input-group-btn">
        <button class="btn btn-info" type="button" id="additem">+</button>
      </span>
      <input type="text" class="form-control" placeholder="关键字" aria-label="keywords">
      <span class="input-group-btn">
        <button class="btn btn-info" type="button">Search</button>
      </span>
    </div>
  </div>
</div>
</div>

<div class="clearfix" style="margin-bottom: 15px;"></div>

<div class="container">
<div class="row">
<div class="col-md-12" >
{#{ hello("Hello,world!") }#}
{% for item in data['rows'] %}
<p><span class="label label-default">{{ item.category.category_name }}</span>  
<button type="button" class="btn btn-primary btn-xs edit" data-id="{{item.id}}">编辑</button>
<button type="button" class="btn btn-primary btn-xs remove pull-right" data-id="{{item.id}}">删除</button>
{{ item.title }}
<figure class="highlight"><pre><code class="language-scss" data-lang="scss">{{ item.content }}</code></pre></figure>
<div class="panel panel-sm">
	<span class="pull-right">by {{item.create_by}}@{{item.modified_time.strftime("%Y-%m-%d %H:%M%:%S")}}</span>
	<a class="addtag" data-id="{{item.id}}">
		+</a>{% for tag in item.tags %}
	<span class="label label-info">{{tag.name}}</span>
	{% endfor %}
</div>

{% endfor %}
</div>
</div>
</div>
{% endblock %}

{% block script %}
{{ super() }}
<script type="text/javascript">
$(function() {
	//$('#btn_save').on("click",function(){});
	$(".edit").on("click",function(){
		var id=$(this).attr("data-id");
		location.href="item_edit/"+id;
	});
	$(".remove").on("click",function(){
		if(!confirm("确认删除?")) return;
		var id=$(this).attr("data-id");
		location.href="item_remove/"+id;
	});
	$("#additem").on("click",function(){
		location.href="item_edit";
	});
	$(".addtag").on("click",function(){
		var id=$(this).data("id");
		loadPopup("item_tags_pool/"+id);
	});
});
</script>
{% endblock %}
